home *** CD-ROM | disk | FTP | other *** search
- /*
-
- parent mode text array make
-
- 1993.6.27 v1.0
- copyright Y.Ouchi
-
- input *intext : log analize result
- *disptext : display text array
-
- output same as input
-
- */
-
- #include <string.h>
- #include <stdlib.h>
- #include "bb.h"
-
- /* 関数プロトタイプ宣言 */
- void parset(struct logcontent *, int, int, short *);
-
- extern int max_textp;
-
- static int textp;
- static int comlevel;
-
- void parmode(struct logcontent *intext,short *disptext)
- {
- int i,j,leng,nextp;
- int startp=0;
- int nowtext;
- int startdsp;
- char nowtitle[8];
- int nowmesno;
- char *workp;
- int textflag;
-
- textflag=0;
- nowtitle[0]=0x00;
- nowmesno=0;
- comlevel=0;
- textp=0;
- nextp=0;
- while (nextp<intext->maxtext){
- for (i=nextp;i<intext->maxtext;i++){
- if (intext->text[i].text.id==TITLE_ID){
- workp=&intext->text[i].title.a;
- for (j=0;j<8;j++) nowtitle[j]=workp[j];
- nowmesno=intext->text[i].title.mes_no;
- disptext[textp++]=i;
- }
- else{
- if (intext->text[i].text.id==NOTITLE_TEXT_ID){
- disptext[textp++]=i;
- }
- else{
- startp=i;
- textflag=1;
- break;
- }
- }
- }
-
- if (textflag==0) break; /* if no text -- break 1994.2.15 */
- startdsp=textp;
- leng=1;
- for (i=startp+1;i<intext->maxtext;i++){
- if (intext->text[i].title.id==TITLE_ID){
- if (strcmp(nowtitle,&intext->text[i].title.a)!=0
- || intext->text[i].title.mes_no!=nowmesno){
- workp=&intext->text[i].title.a;
- for (j=0;j<8;j++) nowtitle[j]=workp[j];
- nowmesno=intext->text[i].title.mes_no;
- break;
- }
- else disptext[textp++]=i;
- }
- leng=leng+1;
- }
- nextp=startp+leng;
-
- nowtext=0;
- while ( nowtext<leng ){
- switch (intext->text[startp+nowtext].text.id){
- case TITLE_ID :
- break;
- case NOTITLE_TEXT_ID :
- disptext[textp++]=startp+nowtext;
- break;
- default :
- if (intext->text[startp+nowtext].text.com_lvl==0){
- parset(intext,startp+nowtext,leng-nowtext,disptext);
- }
- break;
- }
- nowtext=nowtext+1;
- }
-
- nowtext=startdsp+leng-1;
- while ( nowtext>startdsp ){
- if (intext->text[disptext[nowtext]].text.id==TEXT3C_ID
- || intext->text[disptext[nowtext]].text.id==TEXT5C_ID){
- if (abs(intext->text[disptext[nowtext]].text.com_lvl)>0){
- for (i=nowtext-1;i>startp;i--){
- if (abs(intext->text[disptext[i]].text.com_lvl) <
- abs(intext->text[disptext[nowtext]].text.com_lvl)){
- break;
- }
- else{
- if (abs(intext->text[disptext[i]].text.com_lvl) ==
- abs(intext->
- text[disptext[nowtext]].text.com_lvl))
- intext->text[disptext[i]].text.com_lvl=
- abs(intext->text[disptext[i]].text.com_lvl)
- *(-1);
- }
- }
- }
- }
- nowtext=nowtext-1;
- }
-
- }
-
- max_textp=textp;
-
- return;
- }
-
- /*
- parent text set (recursive call)
- 1993.6.09 v.00
- copyright Y.Ouchi
-
- input text
- text number
- length
- output nothing
-
- */
-
- void parset(struct logcontent *intext, int sp, int len, short *dispt)
- {
- int i,textnosave;
-
- comlevel=comlevel+1;
- dispt[textp++]=sp;
- textnosave=intext->text[sp].text.text_no;
- i=1;
- len=len-1;
- while ( len>0 ) {
- switch (intext->text[sp+i].text.id){
- case TEXT3C_ID :
- case TEXT5C_ID :
- if (intext->text[sp+i].text.com_no==textnosave
- && intext->text[sp+i].text.com_lvl==0){
- intext->text[sp+i].text.com_lvl=comlevel;
- parset(intext,sp+i,len,dispt);
- }
- break;
- }
- i=i+1;
- len=len-1;
- }
- comlevel=comlevel-1;
- return;
- }
-